<%@page contentType="text/html;charset=utf-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <%@ include file="/assets/public.jsp"%>
    <title>我的用户列表</title>

</head>
<body>
<%@include file="/assets/header.jsp"%>

<div class="d-flex align-items-stretch">
    <!-- Sidebar Navigation-->
    <%@ include file="/assets/side.jsp"%>
    <!-- Sidebar Navigation end-->
    <div class="page-content">
        <div class="page-header">
            <div class="container-fluid">
                <h2 class="h5 no-margin-bottom">我的关注列表</h2>
            </div>
        </div>
        <section class="no-padding-bottom">

            <div class="list-group myList">
                <ul>
                    <c:forEach items="${userFocus}" var="focus">
                        <c:if test="${focus.user_id != null}">
                            <li class="list-group-item" id="li${focus.id}">
                                <a href="${pageContext.request.contextPath}/user/userDetail?userId=${focus.id}">${focus.real_name}</a>
                                <div style="float: right" class="text-right">
                                    <input type="button" data-id = "${focus.id}" class="btn btn-danger sub" value="取消关注">
                                    <input id="pagePath" type="hidden" value="${pageContext.request.contextPath}"/>
                                </div>
                            </li>
                        </c:if>
                    </c:forEach>
                </ul>
                <nav class="text-center" aria-label="Page navigation">
                    <ul class="pagination">
                        <li>
                            <a href="#" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                        <li><a href="#">1</a></li>
                        <li><a href="#">2</a></li>
                        <li><a href="#">3</a></li>
                        <li><a href="#">4</a></li>
                        <li><a href="#">5</a></li>
                        <li>
                            <a href="#" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </ul>
                </nav>
            </div>
        </section>
        <%@include file="/assets/footer.jsp"%>
    </div>
</div>
</body>
<script>
    $(function () {
        $(".sub").click(function () {
            var path = $("#pagePath").val();
            var focusId = $(this).attr("data-id");
            var liId = "#li"+focusId;
            $.ajax({
                url: path + "/user/focus",
                type:"post",
                data:{uId:focusId},
                success:function (data) {
                    if (data === "0"){
                        $(liId).css("display","none");
                        layer.msg("取关成功");
                    }
                }
            });
        })
    });
</script>
</html>